package com.lfg.leetcode.leetcode0;

public class No96numTrees {

    public static void main(String[] args) {
        int ret = numTrees(3);
        System.out.println("[" + ret + "]");
    }

    public static int numTrees(int n) {
        if (n < 2) {
            return 1;
        }
        int[] dp = new int[n + 1];
        dp[0] = dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                dp[i] += dp[j] * dp[i - j - 1];
            }
        }
        return dp[n];
    }
}

